package com.ctvit.solr.kit.solr.service;

import com.alibaba.fastjson.JSONObject;
import com.ctvit.solr.kit.cp.DocumentCondition;
import com.ctvit.solr.kit.cp.DocumentParam;

import java.util.List;

/**
 * Solr业务接口
 *
 * @author heyingcheng
 * @email heyingcheng@ctvit.com.cn
 * @date 2019/6/23 20:22
 */
public interface SolrService {

    /**
     * 添加或更新文档
     *
     * @param collection    索引库
     * @param documentParam 添加或更新文档
     * @return com.alibaba.fastjson.JSONObject
     * @author heyingcheng
     * @date 2019/6/27 15:39
     */
    JSONObject saveOrUpdateDocument(String collection, DocumentParam documentParam);

    /**
     * 查询文档
     *
     * @param collection        索引库
     * @param documentCondition 文档查询条件
     * @return com.alibaba.fastjson.JSONObject
     * @author heyingcheng
     * @date 2019/6/27 15:43
     */
    JSONObject selectDocument(String collection, DocumentCondition documentCondition);

    /**
     * 按ID删除文档
     *
     * @param collection 索引库
     * @param id         文档ID
     * @return org.apache.solr.client.solrj.response.UpdateResponse
     * @author heyingcheng
     * @date 2019/6/23 21:38
     */
    JSONObject deleteById(String collection, String id);

    /**
     * 按ID批量删除文档
     *
     * @param collection 索引库
     * @param ids        文档IDs
     * @return org.apache.solr.client.solrj.response.UpdateResponse
     * @author heyingcheng
     * @date 2019/6/23 21:52
     */
    JSONObject deleteByIds(String collection, List<String> ids);

    /**
     * 删除全部文档
     *
     * @param collection 索引库
     * @return org.apache.solr.client.solrj.response.UpdateResponse
     * @author heyingcheng
     * @date 2019/6/23 21:46
     */
    @Deprecated
    JSONObject deleteAll(String collection);
}
